'use strict'
const port = process.env.port || process.env.npm_config_port || 9528; // dev 
const path = require('path');
function resolve(dir) {
  return path.join(__dirname, dir)
}
// const CompressionWebpackPlugin = require('compression-webpack-plugin')
// const productionGzipExtensions = ['js', 'css']
// const isProduction = process.env.NODE_ENV === 'production'
module.exports = {
  publicPath: './',
  outputDir: 'dist',
  assetsDir: 'static',

  // 打包去除map 文件
  productionSourceMap: false,

  // configureWebpack: config => {
  //   if (isProduction) {
  //     config.plugins.push(new CompressionWebpackPlugin({
  //       algorithm: 'gzip',
  //       test: new RegExp('\\.(' + productionGzipExtensions.join('|') + ')$'),
  //       threshold: 0, // 大于该值将会被强制压缩
  //       deleteOriginalAssets: true, // 删除原文件（未压缩的css,js）
  //       minRatio: 1 // 压缩率
  //     }))
  //   }
  // }
  devServer: {
    port,
    open: true,
    overlay: {
      warnings: false,
      errors: true,
    },
    disableHostCheck: true, // 打开内网穿透用，上线可去掉
    proxy: {
      [process.env.VUE_APP_BASE_API]: {
        // target: 'https://start-ca1186.service.tcloudbase.com',
        target: `http://192.168.1.92:${port}/mock`,
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          [`^${process.env.VUE_APP_BASE_API}`]: '',
        },
      },
    }
  },
  configureWebpack: {
    name:'',
    resolve: {
      alias: {
        '@': resolve('src'),
        '~': resolve('public')
      }
    }
  },

  lintOnSave: false
};
